package com.three.pinmore.pin.view.activity;

import android.content.Intent;
import android.os.Handler;
import android.os.Message;

import com.gyf.barlibrary.ImmersionBar;
import com.three.pinmore.R;
import com.three.pinmore.base.BaseActivity;

import java.util.Timer;
import java.util.TimerTask;
/**
 * Created by YWT love meng on 2017/8/31
 */
public class WelcomeActivity extends BaseActivity {
    private int count = 2;
    private Timer timer;

    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            if (count == 0) {
                startActivity(new Intent(WelcomeActivity.this, MainActivity.class));
                finish();
            }
        }
    };

    @Override
    public void initData() {

    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if (timer != null) {
            timer.cancel();
        }
    }

    @Override
    public int getLayoutID() {
        return R.layout.activity_welcome;
    }

    @Override
    public void initView() {
        //设置沉浸式
        ImmersionBar.with(this).init();
        ImmersionBar.with(this).transparentStatusBar().fullScreen(true).destroy();
        timer = new Timer();
        timer.schedule(new TimerTask() {
            @Override
            public void run() {
                count--;
                handler.sendEmptyMessage(0);
            }
        }, 1000, 1000);
    }
}
